package com.servlet.project.service;

import com.servlet.project.entity.Administrator;
import com.servlet.project.entity.Member;
import com.servlet.project.util.JdbcUtil;

import java.util.List;

public class AdministratorService {

    /**
     * 管理员注册
     * @param obj
     * @return
     */
    public int add(List<Object> obj) {
        String sql="insert into administrator(adminname,adminpassword,adminbirthdate,adminsex,adminemail) values(?,?,?,?,?) ";
        int count= JdbcUtil.executeUpdate(sql, obj);
        return count;
    }

    /**
     * 管理员登录
     * @param obj
     * @return
     */
    public Administrator login(List<Object> obj) {
        String sql="select * from administrator where adminname=? and adminpassword=?";
        List<Administrator> administrators= JdbcUtil.executeQuery(sql, obj,Administrator.class);
        if(administrators!=null&&administrators.size()>=1){
            return administrators.get(0);
        }
        return null;
    }

    /**
     * 修改当前管理员个人信息
     * @param objects
     * @return
     */
    public int up(List<Object> objects) {
        String sql="update administrator set adminname=?,adminpassword=?,adminbirthdate=?,adminsex=?,adminemail=? where adminid=? ";
        int count= JdbcUtil.executeUpdate(sql, objects);
        return count;
    }


}
